package barbershop.com.controller;

import barbershop.com.entity.ServiceType;
import barbershop.com.entity.Services;
import barbershop.com.service.ServicesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/services")
public class ServicesController {
    @Autowired
    private ServicesService servicesService;

    @RequestMapping("/add")
    public Services addService(@RequestBody Services services){
        return this.servicesService.insert(services);
    }

    @RequestMapping("/delete")
    public Boolean deleteService(@RequestBody Services services){
        return this.servicesService.delete(services);
    }

    @RequestMapping("/update")
    public Services updateService(@RequestBody Services services){
        return this.servicesService.update(services);
    }

    @RequestMapping("/find")
    public Services findService(@RequestBody Services services){
        return this.servicesService.find(services);
    }

    @RequestMapping("/findAll")
    public List<Services> findAllServices(){
        return this.servicesService.findAll();
    }

    @RequestMapping("/getPage")
    public Page<Services> getPage(@RequestParam(required = false)Integer page,
                                  @RequestParam(required = false)Integer size){
        return this.servicesService.getPage(page, size);
    }

    @RequestMapping("/findByType")
    public List<Services> findServiceByType(@RequestParam Integer serviceTypeId){
        return this.servicesService.findByType(serviceTypeId);
    }
}
